package com.cndw.kungfu.model;

import com.cndw.kungfu.config.ConstantsConfig;
import com.cndw.kungfu.ext.TimeProcesser;

public class DataStaticDay {

	private static DataStaticDay instance;
	private static int lastInit;

	private int worldLevel;

	private DataStaticDay() {
		if (TimeProcesser.getUnixTime() >= ConstantsConfig.getSysCgOpenTime() + 15 * 86400) {
			worldLevel = Context.getGeneralServer().getWorldLevel();
		}
	}

	public static DataStaticDay getInstance() {

		if (instance == null || lastInit < TimeProcesser.getMorningTime()) {
			synchronized (DataStaticDay.class) {
				if (instance == null || lastInit < TimeProcesser.getMorningTime()) {

					DataStaticDay tmp = new DataStaticDay();
					lastInit = TimeProcesser.getMorningTime();
					instance = tmp;

				}
			}

		}
		return instance;
	}

	public int getWorldLevel() {
		return worldLevel;
	}

	public boolean isLoser(int level) {
		return worldLevel >= 50 && level + 20 <= worldLevel;
	}

}
